package com.kingwang.training.designpattern.chainofresponsibility.bo;

import lombok.Data;

import java.time.LocalDateTime;

/**
 * 总经理
 */
@Data
public class GeneralManager extends ApplicationApprover {
    public GeneralManager(String name) {
        super(name);
    }

    @Override
    public void handle(LeaveApplication application) {
        if (application.getLeaveDays() > 7) {
            application.setApprover(getName());
            application.setApproveTime(LocalDateTime.now());

            System.out.println("总经理审批");
        } else {
            ApplicationApprover nextApprover = getNextApprover();
            if (nextApprover != null) {
                nextApprover.handle(application);
            }
        }
    }
}
